package com.ev.k3cloudBusiness.service.impl;

import com.alibaba.fastjson.JSON;
import com.ev.k3cloud.entity.K3CloudAuditEntity;
import com.ev.k3cloud.entity.K3CloudDeleteEntity;
import com.ev.k3cloud.entity.K3CloudSubmitEntity;
import com.ev.k3cloud.entity.K3CloudTopEntity;
import com.ev.k3cloud.enums.K3CloudBillFormId;
import com.ev.k3cloud.service.K3CloudService;
import com.ev.k3cloudBusiness.service.K3StkInStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class K3StkInStockServiceImpl implements K3StkInStockService {
    @Autowired
    K3CloudService k3CloudService;
    @Override
    public String submitStkInStockByIds(String ids) {
        K3CloudSubmitEntity k3CloudSubmitEntity=new K3CloudSubmitEntity();
        k3CloudSubmitEntity.setIds(ids);
        K3CloudTopEntity k3CloudTopEntity=new K3CloudTopEntity();
        k3CloudTopEntity.setFormid(K3CloudBillFormId.PUR_STOCK_IN.getFormId());
        k3CloudTopEntity.setData(k3CloudSubmitEntity);
        return k3CloudService.submit(JSON.toJSONString(k3CloudTopEntity));
    }

    @Override
    public String auditStkInStockByIds(String ids) {
        K3CloudAuditEntity k3CloudAuditEntity=new K3CloudAuditEntity();
        k3CloudAuditEntity.setIds(ids);
        K3CloudTopEntity k3CloudTopEntity=new K3CloudTopEntity();
        k3CloudTopEntity.setFormid(K3CloudBillFormId.PUR_STOCK_IN.getFormId());
        k3CloudTopEntity.setData(k3CloudAuditEntity);
        return k3CloudService.audit(JSON.toJSONString(k3CloudTopEntity));
    }

    @Override
    public String unauditStkInStockByIds(String ids) {
        K3CloudAuditEntity k3CloudAuditEntity=new K3CloudAuditEntity();
        k3CloudAuditEntity.setIds(ids);
        K3CloudTopEntity k3CloudTopEntity=new K3CloudTopEntity();
        k3CloudTopEntity.setFormid(K3CloudBillFormId.PUR_STOCK_IN.getFormId());
        k3CloudTopEntity.setData(k3CloudAuditEntity);
        return k3CloudService.unAudit(JSON.toJSONString(k3CloudTopEntity));
    }

    @Override
    public String deleteStkInStockByIds(String ids) {
        K3CloudDeleteEntity k3CloudDeleteEntity=new K3CloudDeleteEntity();
        k3CloudDeleteEntity.setIds(ids);
        K3CloudTopEntity k3CloudTopEntity=new K3CloudTopEntity();
        k3CloudTopEntity.setFormid(K3CloudBillFormId.PUR_STOCK_IN.getFormId());
        k3CloudTopEntity.setData(k3CloudDeleteEntity);
        return k3CloudService.delete(JSON.toJSONString(k3CloudTopEntity));
    }
}
